home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1998 June / SGI Freeware 1998 June.iso / dist / fw_metamail.idb / usr / freeware / bin / showpicture.z / showpicture
Text File  |  1998-01-21  |  3KB  |  97 lines

  1. #!/bin/csh -fb
  2. # (The "-fb" might need to be changed to "-f" on some systems)
  3. #
  4. # Copyright (c) 1991 Bell Communications Research, Inc. (Bellcore)
  5. # Permission to use, copy, modify, and distribute this material 
  6. # for any purpose and without fee is hereby granted, provided 
  7. # that the above copyright notice and this permission notice 
  8. # appear in all copies, and that the name of Bellcore not be 
  9. # used in advertising or publicity pertaining to this 
  10. # material without the specific, prior written permission 
  11. # of an authorized representative of Bellcore.  BELLCORE 
  12. # MAKES NO REPRESENTATIONS ABOUT THE ACCURACY OR SUITABILITY 
  13. # OF THIS MATERIAL FOR ANY PURPOSE.  IT IS PROVIDED "AS IS", 
  14. # WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
  15. #
  16.  
  17. if (! $?METAMAIL_TMPDIR) then
  18.     set METAMAIL_TMPDIR=/tmp
  19. endif
  20.  
  21. if (! $?X_VIEWER) then
  22. set X_VIEWER="xloadimage -view -quiet -geometry +1+1"
  23. # set X_VIEWER="xv -geometry +1+1"
  24. endif
  25. if ($1 == "-viewer" && $#argv > 1) then
  26.     set X_VIEWER = "$2"
  27.     shift
  28.     shift
  29. endif
  30.  
  31. if (! $?MM_NOTTTY) then
  32.     set MM_NOTTTY=0
  33. endif
  34. if (! $?DISPLAY) then
  35.     echo ""
  36.     echo This message contains a picture, which can currently only be
  37.     echo viewed when running X11.  If you read this message while running
  38.     echo X11, and have your DISPLAY variable set, you will then
  39.     echo be able to see the picture properly.
  40.     echo ""
  41.     if ($MM_NOTTTY) then
  42.         set fname=${METAMAIL_TMPDIR}/sp.$$
  43.         echo "The picture is being automatically stored in the file $fname"
  44.         echo "If you do not want this file, please delete it."
  45.     else
  46.         echo -n "Do you want to write the picture out to a file [y] ? "
  47.         set ANS=$<
  48.         if ("$ANS" =~ n* ||  "$ANS" =~ N* ) exit 0
  49.         while ( 1 == 1)
  50.             echo -n "File name:"
  51.             set fname=$<
  52.             if (! -f $fname) then
  53.                 break
  54.             else
  55.                 echo "$fname already exists. Try again"
  56.             endif
  57.         end
  58.     endif
  59.     cp $1 $fname
  60.     if ($status == 0) echo Wrote file $fname
  61.     exit 0
  62. endif
  63.  
  64. if ($#argv == 0) then
  65.     set SQUIRREL=${METAMAIL_TMPDIR}/sp.$$
  66.     cat > $SQUIRREL
  67. else
  68.     set SQUIRREL="$*"
  69. endif
  70.  
  71. echo NOTE:  TO MAKE THE PICTURE WINDOW GO AWAY, JUST TYPE 'q' IN IT.
  72. if ($#argv == 0) then
  73.     echo "==> TO SAVE THIS IMAGE, COPY THE FILE $SQUIRREL BEFORE EXITING"
  74.     echo ""
  75.     $X_VIEWER $SQUIRREL
  76.     rm $SQUIRREL
  77. else
  78.  
  79. foreach i ($*)
  80.     echo "==> TO SAVE THIS IMAGE, COPY THE FILE $i BEFORE EXITING"
  81.     echo ""
  82.     set dir=$i:h
  83.     if ($dir != $i) then
  84.     # Make the ln sure to work    
  85.     cd $dir
  86.     endif
  87.     ln $i $$.PRESS-q-TO-EXIT 
  88.     if (! $status) then 
  89.         sh -c "$X_VIEWER $$.PRESS-q-TO-EXIT"
  90.         rm $$.PRESS-q-TO-EXIT 
  91.     else
  92.         sh -c "$X_VIEWER $i"
  93.     endif
  94. end
  95. endif
  96.